<style lang="less" scoped>

</style>

<template>
  <div>
    <div class="acpt-list">
      <div class="acpt-list-wrap mb30" >
        <div class="acpt-list-head cf">
          <span class="time f-l">结算单号：</span>
          <em class="org f-r ft12" v-if="data.InvoiceState === 'I01'" >未录发票</em>
          <em class="org f-r ft12" v-if="data.InvoiceState === 'I02'" >已录发票</em>
        </div>
        <div class="acpt-list-body">
          <div class="txt">
            <p>结算金额：￥{{data.Amount}}</p>
            <p>结算时间：{{data.SettleDate | timeshort}}</p>
            <p>结算单位：{{data.SettleCorpName}}</p>
            <p>结算周期：{{data.BeginDate | time}} - {{data.EndDate | time}}</p>
          </div>
        </div>
      </div>

      <div class="detail-goods-list">
        <div class="displayflex list-goods-warp" v-for="item in todolist">
          <div class="pic">
            <img :src="item.PictContent | filterImgUrl">
          </div>
          <div class="msg flex1">
            <p class="ft17">{{item.PurchaseGoodsName}}</p>
            <p>{{item.SupplierGoodsSpec}}</p>
            <p>{{item.Producer}}</p>
            <em class="def-color">共<span class="red">{{item.PurchaseSettleQty}}</span>{{item.PurchaseUnit}}</em>
          </div>
        </div>
        <div class="detail-num">
          <em v-if="todolist.length>0">共{{todolist.length}}种商品</em>小计:<span class="red">￥{{amount | fmoney}}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      Guid:'',
      data: {},
      todolist: [],
      amount:0,
    };
  },
  watch: {
    
  },
  computed: {
    userinfo(){
      return localStorage.getItem('userinfo') === null?null:JSON.parse(localStorage.getItem('userinfo'));
    }
  },
  created() {
    this.Guid = this.$route.query.Guid;
    this.getData();
  },
  destroyed() {
    let tabNo = 1;
    if(this.data.InvoiceState === 'I02'){
      tabNo = 2;
    }
    sessionStorage.setItem('SettleTab', tabNo);
  },
  methods: {
    getData(){
      let query = {
        Guid: this.Guid,
      };
      this.Ajax.post('getSettleDetail',query).then((resp) => {
        if (resp.IsSuccess) {
          this.data = resp.Data;
          this.todolist = this.data.Details;
          this.data.Amount = this.data.Amount.toFixed(2)
          this.todolist.forEach(x => {
            this.amount += x.SettleAmount;
          });
        } else {
          this.Toast({
            message: resp.ErrorMessage || '操作异常，请稍后重试',
          });
        }
      });
    },
  },
}
</script>
